package com.cros.threads;
public class ThreadA {
	public static void main(String [] args) {
		ThreadB b = new ThreadB();
		
		b.start();
		
		 try{
			 Thread.sleep(10);
		 }catch(Exception ex){
			 ex.printStackTrace();
		 }
	
		synchronized(b) {
			//try {
			//	System.out.println("Waiting for b to complete...");
			//	b.wait();
			//} catch (InterruptedException e) {}
				System.out.println("Total is: " + b.total);
			}
	 }
}

class ThreadB extends Thread {
	int total;
	 public void run() {
		 synchronized(this) {
			 for(int i=0;i<1000000;i++) {
				 total += i;
				
			 }
			 notify();
		 }
	 }
}